﻿using Dal;
using Dal.DTO;
using Model;

namespace Bll
{
    public class ShopBll
    {
        public ShopBll(ShopDal dal)
        {
            Dal = dal;
        }

        public ShopDal Dal { get; }
        /// <summary>
        /// 添加门店
        /// </summary>
        /// <param name="shop">一个门店对象</param>
        /// <returns>受影响行数</returns>
        public int Add(Shop shop)
        {
            return Dal.Add(shop);
        }
        /// <summary>
        /// 修改门店
        /// </summary>
        /// <param name="shop">一个门店对象</param>
        /// <returns>受影响行数</returns>
        public int Update(Shop shop)
        {
            return Dal.Update(shop);
        }
        /// <summary>
        /// 逻辑删除门店
        /// </summary>
        /// <param name="id">主键id</param>
        /// <returns>受影响行数</returns>
        public int Delete(int id)
        {
            return Dal.Delete(id);
        }
        /// <summary>
        /// 分页显示，门店名称模糊查，门店地址精确查
        /// </summary>
        /// <param name="index">当前页</param>
        /// <param name="size">页容量</param>
        /// <param name="name">门店名称</param>
        /// <param name="addr">门店地址</param>
        /// <returns></returns>
        public ShopDTO GetAll(int index, int size, string? name, string? addr)
        {
            return Dal.GetAll(index, size, name, addr);
        }
        /// <summary>
        /// 通过id获取一个门店对象
        /// </summary>
        /// <param name="id">门店id</param>
        /// <returns>一个门店对象</returns>
        public Shop GetShop(int id)
        {
            return Dal.GetShop(id);
        }
        /// <summary>
        /// 查所有地址
        /// </summary>
        /// <returns>地址集合</returns>
        public List<Addr> GetAddrs()
        {
            return Dal.GetAddrs();
        }
    }
}
